package com.ldkj.panzh.utils;

import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.ldkj.panzh.param.ArtemisParam;
import com.ldkj.panzh.param.BaseParam;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 公共工具类
 *
 * @author qiancheng
 * @date 2025-11-18
 */
@Component
public class CommentUtils {

    @Value("${hikvision.artemis.host}")
    private String defaultHost;

    @Value("${hikvision.artemis.appKey}")
    private String defaultAppKey;

    @Value("${hikvision.artemis.appSecret}")
    private String defaultAppSecret;

    /**
     * 创建Artemis配置对象（使用配置文件中的默认值）
     */
    public ArtemisConfig createArtemisConfig() {
        ArtemisConfig config = new ArtemisConfig();
        config.setAppKey(defaultAppKey);
        config.setAppSecret(defaultAppSecret);
        config.setHost(defaultHost);
        return config;
    }

    /**
     * 创建Artemis配置对象（使用自定义host，appKey和appSecret使用配置文件默认值）
     */
    public ArtemisConfig createArtemisConfig(String host) {
        ArtemisConfig config = new ArtemisConfig();
        config.setAppKey(defaultAppKey);
        config.setAppSecret(defaultAppSecret);
        config.setHost(host != null && !host.isEmpty() ? host : defaultHost);
        return config;
    }

    /**
     * 创建Artemis配置对象（兼容旧方法，但优先使用配置文件的值）
     */
    public ArtemisConfig createArtemisConfig(String appKey, String appSecret, String host) {
        ArtemisConfig config = new ArtemisConfig();
        config.setAppKey(appKey != null && !appKey.isEmpty() ? appKey : defaultAppKey);
        config.setAppSecret(appSecret != null && !appSecret.isEmpty() ? appSecret : defaultAppSecret);
        config.setHost(host != null && !host.isEmpty() ? host : defaultHost);
        return config;
    }

}
